<%@ page language="java" contentType="text/html; charset=UTF-8"
         pageEncoding="UTF-8" %>
<%@taglib prefix="mvc" uri="http://www.springframework.org/tags/form" %>
<%@taglib prefix="fmt" uri="http://www.springframework.org/tags" %>
<%
    String path = request.getContextPath();
    String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort() + path + "/";
%>
<html>
<head>
    <title>预算权限设置</title>

    <style>
        .news {
            cursor: pointer;
        }
    </style>
    <link rel="stylesheet" href="../../lib/layui/layui/css/layui.css">
    <link rel="stylesheet" href="/css/workflow/work/automaticNumbering.css">
    <link rel="stylesheet" type="text/css" href="../css/base.css">
    <script type="text/javascript" src="/js/jquery/jquery.min.js"></script>
    <script type="text/javascript" src="/lib/layer/layer.js?20201106"></script>
    <script type="text/javascript" src="/lib/laydate/laydate.js"></script>
    <script type="text/javascript" src="../../lib/layui/layui/layui.js"></script>
    <script type="text/javascript" src="/js/base/base.js"></script>
    <script type="text/javascript" src="/lib/jquery.form.min.js"></script>
    <link rel="stylesheet" type="text/css" href="/css/commonTheme/${sessionScope.InterfaceModel}/commonTheme.css"/>

    <style>

        .sendsave senduser {
            height: 30px;
            line-height: 30px;
            width: auto;
            padding: 0 20px;
        }

        .btnSure {
            background-image: url(../../img/confirm.png);
            width: 70px;
            height: 28px;
            margin: 2px auto;
            line-height: 28px;
            cursor: pointer;
            position: absolute;
            left: 40%;
            bottom: 47%
        }

        table {
            width: 70%;
            margin: 0 auto;
            margin-top: 25px;
        }

        .divtable {
            position: relative
        }

        input[type="checkbox"], input[type="radio"] {
            background: transparent;
            border: 0;
        }

    </style>
</head>
<body style="background: #fff">

<div class="maintop clearfix" style="">
    <p style="margin-left: 5px">
        <img src="/img/commonTheme/${sessionScope.InterfaceModel}/wangguan.png"
             style="width: 25px;height: 24px;vertical-align: text-bottom;" alt="">
        <label>预算权限设置</label><%--内部接口配置--%>
    </p>

    <%--<a  class="newsBtn newsBtntwo btnTheme " id="newBtn1" style="float: right;margin-right: 3%;margin-top: 5px;" href="javascript:void (0)" data-num="0"><img src="../../img/mywork/newbuildworjk.png" alt="" style="margin:-3px 0px 0px -8px;"><fmt:message code="global.lang.new" /></a>&lt;%&ndash;新建&ndash;%&gt;--%>
</div>

<div class="divtable">
    <table class="tr_td">
        <thead>
        <tr>
            <th style="width:25%;height: 35px; font-size: 15px; color: #2F5C8F;"><fmt:message
                    code="workflow.th.name"/></th>
            <th style="width:75%;height: 35px;font-size: 15px; color: #2F5C8F;"><fmt:message
                    code="notice.th.content"/></th>
        </tr>
        </thead>
        <tbody>


        <tr>
            <td>
                <fmt:message code="netdisk.th.Scope(personnel)"/>

            </td>
            <td>
                <textarea name="txt" id="outPriv" user_id="" class="sendsave senduser" disabled rows="3"
                          cols="50"></textarea>
                <a style="margin-left: 10px;cursor: pointer" id="adduesr"><fmt:message code="global.lang.add"/></a>
                <a style="margin-left: 10px;cursor: pointer" id="del_user"><fmt:message code="global.lang.empty"/></a>


            </td>
        </tr>
        <tr>
            <td>
                授权范围(角色)
            </td>
            <td>
                <textarea name="txt" id="Priv" user_id="" class="sendsave senduser" disabled rows="3"
                          cols="50"></textarea>
                <a style="margin-left: 10px;cursor: pointer" id="addpriv"><fmt:message code="global.lang.add"/></a>
                <a style="margin-left: 10px;cursor: pointer" id="del_priv"><fmt:message code="global.lang.empty"/></a>


            </td>
        </tr>


        <div class="btnSure" style=" left: 45%; bottom: -50%;">
            <span style="margin-left: 32px;" id="okbtn"><fmt:message code="global.lang.ok"/></span>
        </div>

        </tbody>
    </table>
</div>
</div>
</body>
<script type="text/javascript">


    var userIds;
    var privNos;


    //获取权限信息
    $(function () {


        $('#del_user').click(function () { //清空人员
            $('#outPriv').attr('user_id', '');

            $('#outPriv').val('');
        });
        $('#del_priv').click(function () { //清空人员
            $('#Priv').attr('privId', '');
            $('#Priv').attr('userpriv', '')

            $('#Priv').val('');
        });

        $.ajax({
            url: '/budget/seeEditAuth',
            dataType: 'json',
            success: function (data) {
                $('#outPriv').val(data.obj[0]);
                $('#Priv').val(data.obj[1]);
                userIds = data.obj[2];
                privNos = data.obj[3];

                if(data.flag){
                    $('#outPriv').val(data.object[0]);
                    $('#outPriv').attr('user_id',data.object[2])
                    $('#Priv').val(data.object[1]);
                    $('#Priv').attr('privId',data.object[3]);
                }


            }
        });
    });
    var user_id = '';



        $("#adduesr").click(function () {
            user_id = 'outPriv';
            $.popWindow("../common/selectUser");
        });
        $("#addpriv").click(function () {
            priv_id = 'Priv';
            $.popWindow("../common/selectPriv");
        });




            var userId = $('[id="outPriv"]').attr('user_id');
            var privNo = $('[id="Priv"]').attr('privId');

            $(".btnSure").click(function () {

                $.ajax({
                    type: 'get',
                    url: '/budget/setEditAuth',
                    dataType: 'json',
                    data: {

                        User: userId,
                        Priv: privNo,

                        User: $('[id="outPriv"]').attr('user_id'),
                        Priv: $('[id="Priv"]').attr('privId')

                    },
                    success: function (data) {
                        if (data.flag) {
                            layer.msg('<fmt:message code="netdisk.th.Success" />!', {icon: 6});
                        }
                    }
                });

            })


</script>
</html>
